package cn.itcast.gateway.fallback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 虎哥
 */
@Slf4j
@RestController
@RequestMapping("hystrix")
public class FallBackController {

    @RequestMapping("fallback")
    public Map<String, String> handleFallback(Throwable t){
        log.error("网关路由触发降级，原因：", t);
        Map<String, String> response = new HashMap<>();
        response.put("code", "500");
        response.put("msg", "服务太拥挤了，稍后再试！");
        return response;
    }
}
